package com.lxhll.personnel.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lxhll.personnel.entity.Employee;
import com.lxhll.personnel.entity.EmployeeRole;
import com.lxhll.personnel.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (EmployeeRole)表数据库访问层
 *
 * @author makejava
 * @since 2021-07-25 16:18:15
 */
@Mapper
public interface EmployeeRoleDao extends BaseMapper<EmployeeRole> {
    /**
     * 根据员工ID，查询拥有的所有角色
     * @param employeeId
     * @return
     */
    @Select( "select r.* from role r,employee_role er where er.employee_id=#{employeeId} and r.id=er.role_id")
    public List<Role> getRoleByEmployeeId(Integer  employeeId);



    /**
     * 根据角色ID，查询分配到的所有员工
     * @param roleId
     * @return
     */
    @Select( "select e.* from employee e,employee_role er where er.role_id=#{roleId} and e.id=er.employee_id")
    public List<Employee>  getEmployeeByRoleId(Integer roleId);
}
